1. Technical Field
The present invention relates generally to an improved data processing system and in particular, a method and apparatus for processing data. Still more particularly, the present invention provides a method, apparatus, and computer instructions for generating data used in detecting memory leaks.
2. Description of Related Art
In designing and creating programs, various tests and debugging procedures are performed to ensure that the programs are performing up to an expected level or standard. Debugging software is used to find the errors in the program logic. Different types of debugging may be performed on a program. One type of debugging that occurs in a software production environment involves debugging memory leaks.
A memory leak is a condition caused by a program that does not free up the extra memory that the program allocates. In programming languages, such as C/C++, a programmer can dynamically allocate additional memory to hold data and variables that are required for the moment, but not used throughout the program. When those memory areas are no longer needed, these memory areas should be deallocated.
When memory is allocated for storing information that has no future use, but it continues to occupy memory, a memory leak is said to have occurred. If too many memory leaks occur, these memory leaks may use up all of the memory and bring everything to a halt, or slow the processing considerably. In other environments, such as Java, the Java virtual machine allocates and deallocates memory automatically. In Java, when objects are created in the memory and they continue to reside in the heap after their use, a memory leak can occur, especially if those objects do not have any future use.
Existing tools for debugging memory leaks are too heavy weight to make them practical. Further, debugging memory leak problems using profilers in a software production environment is either impossible or impractical because it is a high risk proposition. Debugging memory leaks using commercial profilers is a long and tedious process, requiring specialized skills. Further, it is often not possible for a customer to reproduce problems in a test environment.
Heap dumps may be used in a production environment in an attempt to identify memory leaks. A heap is a common pool of memory that is available to a program. The management of the heap may be performed either by the applications themselves, allocating and deallocating memory as required, or by the operating system or other system program. A heap dump involves obtaining the contents of the heap. These contents are often placed or “dumped” into a log file for analysis. This data is often used to determine whether memory leaks are present.
Generating heap dumps in a software production environment is an expensive process. Further, it is often impossible to generate a heap dump because of resource restrictions in the production environment. With the large size of a heap, a high risk of crashing a system, such as a Java virtual machine (JVM), is present when a heap dump is generated. Further, once a heap dump is generated, the size of the log file is typically so large that interpretation of this data requires highly skilled experts. These logs are typically greater than one gigabyte of text. Customers typically do not have the skill needed and many software production companies have very few people with the necessary skill. Additionally, when a heap dump is being generated and written into a file, the heap is locked. In other words, during this time no other thread may run within the JVM. Hence, during the time heap dump is being generated, the JVM can not perform any other activity. All work is halted temperately. It is highly desirable to minimize the time for generating a dump. As the time it takes to write the heap data to the log file is directly proportional to the amount of data to be written, there is little that a user can do to reduce the time it takes to write heap dump to a file.
Generating a heap dump may take several minutes and several heap dumps are typically needed to properly debug a problem involving memory leaks in a heap. Consequently, it is difficult and tedious to debug memory leaks using currently available techniques.
Therefore, it would be advantageous to have an improved method, apparatus, and computer instructions for generating data for use in detecting memory leaks.